<template>
  <div>
    <div>助记词：{{ words }}</div>
    <div>地址：{{ address }}</div>
    <div>私钥：{{ privateKey }}</div>
  </div>
</template>
<script setup>
import { generateMnemonic, mnemonicToSeed } from "bip39";
import { ref } from "vue";
import { hdkey } from "ethereumjs-wallet";

let words = ref();
let address = ref();
let privateKey = ref();

async function init() {
  words.value = generateMnemonic(); // 生成助记词
  let seed = await mnemonicToSeed(words.value); // 生成种子
  console.log(seed);

  // let hdwallet = hdkey.fromMasterSeed(seed); // 生成HD钱包
  // let keypair = hdwallet.derivePath("m/44'/60'/0'/0/0"); //.getWallet() // 生成密钥对
  // console.log(keypair, "密钥对");
  // let wallet = keypair.getWallet(); // 生成钱包
  // console.log(wallet, "钱包");

  // address.value = wallet.getAddressString(); // 生成地址
  // let checkAddress = wallet.getChecksumAddressString(); // 生成校验地址

  // privateKey.value = wallet.getPrivateKey().toString("hex"); // 生成私钥
}

init();
</script>
<style scoped>
div {
  text-align: left;
}
</style>
